package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmCollectionmoneyEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmCollectionmoneyMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 收款信息Service接口
 * @author: yhli
 * @date 2020-06-27 14:43
 */
@Service
public class bpmCrmCollectionmoneyService extends ServiceImpl<bpmCrmCollectionmoneyMapper,bpmCrmCollectionmoneyEntity> {

	@Resource
	private bpmCrmCollectionmoneyMapper bpmCrmCollectionmoneyMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmCollectionmoneyEntity> queryWrapper = new QueryWrapper<bpmCrmCollectionmoneyEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String paymentMethod = (String) params.get("paymentMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(paymentMethod), "payment_method", paymentMethod);
          String transactionDate = (String) params.get("transactionDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(transactionDate), "transaction_date", transactionDate);
          String enterAmount = (String) params.get("enterAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(enterAmount), "enter_amount", enterAmount);
          String payerName = (String) params.get("payerName");
        queryWrapper.like(ToolUtil.isNotEmpty(payerName), "payer_name", payerName);
          String payerProofFilepath = (String) params.get("payerProofFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(payerProofFilepath), "payer_proof_filepath", payerProofFilepath);
          String payerMemo = (String) params.get("payerMemo");
         queryWrapper.eq(ToolUtil.isNotEmpty(payerMemo), "payer_memo", payerMemo);
          String amountReceived = (String) params.get("amountReceived");
         queryWrapper.eq(ToolUtil.isNotEmpty(amountReceived), "amount_received", amountReceived);
          String cashierMemo = (String) params.get("cashierMemo");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierMemo), "cashier_memo", cashierMemo);
          String cashierProofFilepath = (String) params.get("cashierProofFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierProofFilepath), "cashier_proof_filepath", cashierProofFilepath);
          String checkmoneyReceiptnumber = (String) params.get("checkmoneyReceiptnumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(checkmoneyReceiptnumber), "checkmoney_receiptnumber", checkmoneyReceiptnumber);
          String receivedDate = (String) params.get("receivedDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(receivedDate), "received_date", receivedDate);
          String cashierReview = (String) params.get("cashierReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierReview), "cashier_review", cashierReview);
          String orderTakeEffectTime = (String) params.get("orderTakeEffectTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderTakeEffectTime), "order_take_effect_time", orderTakeEffectTime);
          String collectionTime = (String) params.get("collectionTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(collectionTime), "collection_time", collectionTime);
          String intervalDay = (String) params.get("intervalDay");
         queryWrapper.eq(ToolUtil.isNotEmpty(intervalDay), "interval_day", intervalDay);
             String costOfCapital = (String) params.get("costOfCapital");
         queryWrapper.eq(ToolUtil.isNotEmpty(costOfCapital), "cost_of_capital", costOfCapital);
          String financeManagerReview = (String) params.get("financeManagerReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(financeManagerReview), "finance_manager_review", financeManagerReview);
          String managerReview = (String) params.get("managerReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(managerReview), "manager_review", managerReview);
  		Page<bpmCrmCollectionmoneyEntity> page = bpmCrmCollectionmoneyMapper.selectPage(new Query<bpmCrmCollectionmoneyEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmCollectionmoneyEntity bpmCrmCollectionmoneyEntity) {
		Page<bpmCrmCollectionmoneyEntity> page = bpmCrmCollectionmoneyMapper.findPage(new Query<bpmCrmCollectionmoneyEntity>(params).getPage(), bpmCrmCollectionmoneyEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmCollectionmoneyByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmCollectionmoneyById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmCollectionmoney(bpmCrmCollectionmoneyEntity bpmCrmCollectionmoney){
        bpmCrmCollectionmoney.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmCollectionmoney);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmCollectionmoneyById(bpmCrmCollectionmoneyEntity bpmCrmCollectionmoney) {
		return updateById(bpmCrmCollectionmoney);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmCollectionmoneyEntity getbpmCrmCollectionmoneyById(String id){
		return getById(id);
	}
}
